package com.huawei.appgallery.foundation.ui.framework.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appmarket.framework.widget.RenderButton;
import java.lang.ref.WeakReference;
import o.azb;
import o.dky.d;
import o.dky.h;
import o.dky.i;
import o.evf;

public class NodataWarnLayout extends LinearLayout {
    private RenderButton ʽ;
    private TextView ˊ;
    private TextView ˋ;
    private ImageView ˎ;
    private TextView ˏ;
    private TextView ॱ;
    private TextView ॱॱ;
    private TextView ᐝ;

    static class b implements OnGlobalLayoutListener {
        private WeakReference<TextView> ˎ;

        private b(TextView textView) {
            this.ˎ = new WeakReference(textView);
        }

        public void onGlobalLayout() {
            TextView textView = (TextView) this.ˎ.get();
            if (textView != null) {
                textView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                if (textView.getLineCount() <= 1) {
                    textView.setGravity(17);
                } else {
                    textView.setGravity(19);
                }
            }
        }
    }

    public enum e {
        WARN_IMAGE,
        WARN_TEXTONE,
        WARN_TEXTTWO,
        WARN_BTN,
        TITLE_DESC,
        CONTENT_DESCONE,
        CONTENT_DESCTWO,
        CONTENT_DESCTHREE
    }

    public NodataWarnLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(i.ˎ, this);
        azb.ˏ(inflate);
        evf.ॱ(inflate, d.ॱˊ);
        this.ˎ = (ImageView) inflate.findViewById(h.ॱꓸ);
        this.ॱ = (TextView) inflate.findViewById(h.ॱﹳ);
        this.ˏ = (TextView) inflate.findViewById(h.ॱﾞ);
        this.ˋ = (TextView) inflate.findViewById(h.ॱˉ);
        this.ˊ = (TextView) inflate.findViewById(h.ॱᐝ);
        this.ᐝ = (TextView) inflate.findViewById(h.ॱˎ);
        this.ॱॱ = (TextView) inflate.findViewById(h.ᐝॱ);
        this.ʽ = (RenderButton) inflate.findViewById(h.ॱᶥ);
    }

    public NodataWarnLayout(Context context) {
        super(context);
    }

    public void setContentDescOne(String str) {
        if (this.ˊ != null) {
            this.ˊ.setText(str);
        }
    }

    public void setContentDescTwo(String str) {
        if (this.ᐝ != null) {
            this.ᐝ.setText(str);
        }
    }

    public void setContentDescThree(String str) {
        if (this.ॱॱ != null) {
            this.ॱॱ.setText(str);
        }
    }

    public void setTitleDesc(String str) {
        if (this.ˋ != null) {
            this.ˋ.setText(str);
        }
    }

    public void setWarnTextTwo(int i) {
        if (this.ˏ != null) {
            this.ˏ.setText(i);
        }
    }

    public void setWarnTextTwo(String str) {
        if (this.ˏ != null) {
            this.ˏ.setText(str);
        }
    }

    public void setWarnTextOne(int i) {
        if (this.ॱ != null) {
            this.ॱ.setText(i);
        }
    }

    public void setWarnTextOne(String str) {
        if (this.ॱ != null) {
            this.ॱ.setText(str);
        }
    }

    private void ˋ(TextView textView) {
        if (textView.getVisibility() == 0) {
            textView.getViewTreeObserver().addOnGlobalLayoutListener(new b(textView));
        }
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        ˋ(this.ॱ);
        ˋ(this.ˏ);
    }

    public void setWarnImage(int i) {
        evf.ˏ(this.ˎ, i);
    }

    public void setWarnBtnText(int i) {
        if (this.ʽ != null) {
            this.ʽ.setText(i);
        }
    }

    public void setWarnBtnOnClickListener(OnClickListener onClickListener) {
        if (this.ʽ != null) {
            this.ʽ.setOnClickListener(onClickListener);
        }
    }

    public void setViewVisible(e eVar, int i) {
        switch (eVar) {
            case WARN_TEXTTWO:
                if (this.ˏ != null) {
                    this.ˏ.setVisibility(i);
                    return;
                }
                return;
            case WARN_BTN:
                if (this.ʽ != null) {
                    this.ʽ.setVisibility(i);
                    return;
                }
                return;
            case TITLE_DESC:
                if (this.ˋ != null) {
                    this.ˋ.setVisibility(i);
                    return;
                }
                return;
            case CONTENT_DESCONE:
                if (this.ˊ != null) {
                    this.ˊ.setVisibility(i);
                    return;
                }
                return;
            case CONTENT_DESCTWO:
                if (this.ᐝ != null) {
                    this.ᐝ.setVisibility(i);
                    return;
                }
                return;
            case CONTENT_DESCTHREE:
                if (this.ॱॱ != null) {
                    this.ॱॱ.setVisibility(i);
                    return;
                }
                return;
            default:
                return;
        }
    }
}
